package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.framework.widget.ArrowImageView;
import com.huawei.appmarket.framework.widget.RenderFrameLayout;
import com.huawei.appmarket.framework.widget.RenderImageView;
import com.huawei.appmarket.service.appdetail.view.widget.MultiLineTextView;
import com.huawei.appmarket.service.appdetail.view.widget.MultiLineTextView.e;
import o.azb;
import o.cgz;
import o.Logger;
import o.eqx;
import o.eqz;
import o.erq;
import o.ewm;
import o.ewm.j;

public class PosterCard extends BaseDistCard implements e, eqz {
    private String ʻ;
    protected RenderImageView ʼ;
    private ArrowImageView ʽ;
    protected RenderFrameLayout ˋ;
    private boolean ˋॱ = false;
    private Context ˏॱ;
    private int ॱॱ = 1;
    private MultiLineTextView ᐝ;

    public PosterCard(Context context) {
        super(context);
        this.ˏॱ = context;
    }

    public cgz ˏ(View view) {
        this.ʼ = (RenderImageView) view.findViewById(j.ʻˊ);
        this.ᐝ = (MultiLineTextView) view.findViewById(j.ˋ);
        this.ʽ = (ArrowImageView) view.findViewById(j.ˎـ);
        this.ˋ = (RenderFrameLayout) view.findViewById(j.ʾˊ);
        ʽ(view);
        ˊ(view);
        return this;
    }

    private void ˊ(View view) {
        this.ˋ.setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ PosterCard ॱ;

            {
                this.ॱ = r1;
            }

            public void onClick(View view) {
                this.ॱ.ˊ();
            }
        });
        int ˊ = azb.ˊ(this.ˏॱ);
        this.ˋ.setPadding(ˊ, this.ˋ.getPaddingTop(), ˊ, this.ˋ.getPaddingBottom());
        this.ᐝ.setMaxLine(this.ॱॱ);
        this.ᐝ.setOnContentChangedListener(this);
        this.ᐝ.setResize(true);
    }

    private void ˊ() {
        if (this.ˋॱ) {
            this.ˋॱ = false;
            this.ʽ.setArrowUp(false);
        } else {
            this.ˋॱ = true;
            this.ʽ.setArrowUp(true);
        }
        this.ᐝ.ˎ();
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        ˎ(this.ʼ, ((BaseCardBean) cardBean).ˑॱ(), cardBean.ॱˌ());
        if (this.ˋॱ) {
            this.ʽ.setArrowUp(true);
        } else {
            this.ʽ.setArrowUp(false);
        }
        if (cardBean.O_() != null) {
            this.ʻ = cardBean.O_();
            if (this.ᐝ.ˏ() != null && !this.ˋॱ) {
                this.ᐝ.setSimpleContent(this.ᐝ.ˏ());
            } else if (this.ᐝ.ॱ() == null) {
                this.ᐝ.setContent(this.ʻ);
            } else {
                this.ᐝ.setContent(this.ᐝ.ॱ());
            }
            this.ᐝ.setVisibility(0);
            return;
        }
        this.ᐝ.setVisibility(8);
        this.ʽ.setVisibility(8);
    }

    public void ˊ(boolean z) {
        if (z) {
            this.ʽ.setVisibility(0);
        } else {
            this.ʽ.setVisibility(8);
        }
    }

    public void ˊ(ImageView imageView, String str, String str2, LayoutParams layoutParams) {
        eqx.ˎ(imageView, str, str2, this, true);
    }

    public void ॱ(Bitmap bitmap) {
        if (bitmap != null) {
            try {
                Drawable drawable;
                Drawable drawable2;
                int ˎ = erq.ˎ(bitmap);
                this.ʼ.setRenderColor(ˎ);
                this.ˋ.setBackgroundColor(ˎ);
                boolean ˏ = erq.ˏ(ˎ);
                Logger.ˎ("PosterCard", "onImageLoaded rendercolor=" + ˎ + ",isDeepColor=" + ˏ);
                if (ˏ) {
                    this.ᐝ.setTextColor(this.ˏॱ.getResources().getColor(17170443));
                    drawable = this.ˏॱ.getResources().getDrawable(ewm.e.ॱʼ);
                    drawable2 = this.ˏॱ.getResources().getDrawable(ewm.e.ॱʽ);
                } else {
                    this.ᐝ.setTextColor(this.ˏॱ.getResources().getColor(17170444));
                    drawable = this.ˏॱ.getResources().getDrawable(ewm.e.ॱʻ);
                    drawable2 = this.ˏॱ.getResources().getDrawable(ewm.e.ˏˏ);
                }
                this.ʽ.setArrowDrawable(drawable, drawable2);
                this.ʽ.setArrowUp(false);
            } catch (IllegalStateException e) {
                Logger.e("poster", e.toString());
            }
        }
    }
}
